#include<iostream>
#include<vector>
using namespace std;

int main()
{
    long long n;
    string str;
    cin >> n >> str;
    vector<long long> s(n, 0);
    vector<long long> h(n, 0);
    vector<long long> y(n, 0);
    s[0] = str[0] == 's' ? 1 : 0;
    for (long long i = 1; i < str.size(); i++)
    {
        s[i] = str[i] == 's' ? s[i - 1] + 1 : s[i - 1];
        h[i] = str[i] == 'h' ? h[i - 1] + s[i - 1] : h[i - 1];
        y[i] = str[i] == 'y' ? y[i - 1] + h[i - 1] : y[i - 1];
    }

    cout << y.back() << endl;
    return 0;
}